define(["app", "angular", "services/BaseService"], function(app, angular) {
	
	var deps = ["$http", "BaseService"];
	
	function companyResource($http, BaseService) {
        return initResource($http, BaseService.restfulUrl + "company/", BaseService.formHeader);
    }
	
	var postHeader = {
	        "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8"
	};
	
	function initResource($http, preUrl,formHeader) {
        return {
        	save: function (companyVo) {
				return $http.post(preUrl + "saveOrUpdateCompamy", angular.toJson(companyVo));
			},
			update: function (companyVo) {
				return $http.post(preUrl + "saveOrUpdateCompamy", angular.toJson(companyVo));
			},
			queryOrgList:function(orgPid){
                return $http.get(preUrl +orgPid+ "/queryOrgList");
            },
            deleteCar:function(cardId){
                return $http.get(preUrl +cardId+ "/deleteCar");
            },
            queryCompanyVoById:function(id){
                return $http.get(preUrl +id+ "/queryCompanyVoById");
            },
            recharge: function (rechargeAmount,companyCode,id) {
        		return $http.post(preUrl+"recharge",{
        			rechargeAmount:rechargeAmount,
        			companyCode:companyCode,
        			id:id,
                },{
                    headers: postHeader
                });
			},
			queryRechargeLog: function (companyCode,pageNo,pageSize,id) {
                return $http.get(preUrl + "queryRechargeLog", {
                    params: {
                    	companyCode: companyCode,
                    	id: id,
                        pageSize: pageSize || 10000,
                        pageNo: pageNo || 1
                    }
                });
            },
			
			
            queryCompanyList: function (pageNo,pageSize,timeStamp) {
                return $http.get(preUrl + "queryCompanyList", {
                    params: {
                    	timeStamp: timeStamp,
                        pageSize: pageSize || 10000,
                        pageNo: pageNo || 1
                    }
                });
            },
        };
        
    }
	companyResource.$inject = deps;
	app.lazy.factory("AddCompanyResource", companyResource);
});
